package com.syqc.monitor.ui.alarm

import android.text.Html
import com.syqc.monitor.ParamsUtil
import com.syqc.monitor.R
import com.syqc.utils.AlarmDataUtil
import com.syqc.utils.Keys

/**
 *@Author Jasper
 *@Time   2020/12/9
 *@Desc   主动安全报警
 */
class AdasAlarmActivity : BaseAlarmActivity() {
    override val isAdas: Boolean
        get() = true


    override fun initView() {
        super.initView()
        val carIdExtra = intent.getStringExtra(Keys.INTENT_CAR_ID)
        if (carIdExtra != null) return
        val adas = ParamsUtil.getAdasParams()
        if (adas.isNullOrEmpty()) return
        mViewModel.typeIds = adas[0]
        AlarmDataUtil.instance.getChooseByIds(true, mViewModel.typeIds)
        binding.lrTvAlarmType.setRightText(
            Html.fromHtml(
                mViewModel.getHtml(
                    getString(R.string.desc_selected),
                    mViewModel.typeIds.split(",").size,
                    AlarmDataUtil.instance.getTotal(isAdas),
                    isAdas
                )
            )
        )


        binding.editAlarmRunSpeed.setText(adas[1])
        binding.editAlarmContinue.setText(adas[2])
    }

    override fun saveSet() {
        ParamsUtil.saveAdasParams(
            mViewModel.typeIds,
            mViewModel.runSpeed,
            mViewModel.duration
        )
    }

}